<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>客户管理</title>
  <link href="../../css/style.css" rel="stylesheet" type="text/css" />
  <!--axios-->
  <script type="text/javascript" src="../../js/axios.js"></script>
  <script type="text/javascript" src="../../js/jquery-3.3.1.js"></script>
  <script type="text/javascript" src="../../js/api.js"></script>
  <link rel="stylesheet" href="../../layui/css/layui.css">
  <script type="text/javascript" src="../../layui/layui.js"></script>
  <script>
    $(function (){
      load(1,5,"","","","");
      // 省、市的下拉菜单事件
      addressMenuInit($("#country"),$("#city"))
      //查询按钮触发的事件
      $(".subBut").click(function (){
        window.event.returnValue=false;
        company=$("#company").val();
        customName=$("#customname").val();
        province=$("#country").val();
        city=$("#city").val();
          load(1,5,company,customName,province,city)
        layui.use('layer', function(){
          var layer = layui.layer;
          layer.msg("查询成功！",{icon:1})
        });
      })
    })

    function load(currentpage,rows,company,customName,province,city){
      var url="http://121.37.227.40:8000/"
      axios({
        url:url+'marketing/marketingPage',
        method:"POST",
        data:{
        },
        params:{
          currentPage: currentpage,
          rows: rows,
          company:company,
          customName:customName,
          province:province,
          city:city
        },
        dataType:"JSON"
      }).then(function (rel) {

        let lis='<thead>\n' +
                '        <tr>\n' +
                '          <th>序号</th>\n' +
                '          <th>客户姓名</th>\n' +
                '          <th>性别</th>\n' +
                '          <th>联系电话</th>\n' +
                '          <th>所属公司</th>\n' +
                '          <th>所属区域</th>\n' +
                '          <th>分配时间</th>\n' +
                '          <th>客服人员</th>\n' +
                '          <th>操作</th>\n' +
                '        </tr>\n' +
                '      </thead>'
        lis+='<tbody>';
        rel = rel.data;
        console.log(rel)
        let li
        for (let i=0;i<rel.resultData.list.length;i++){
          let data=rel.resultData.list[i];
          let sex=data.sex;
          if(data.sex==1){
            sex = "男";
          }else if(data.sex==2){
            sex = "女";
          }
          li+='<tr>\n' +
                  '          <td>' + ((i + 1) +((currentpage-1)*rows))+ '</td>\n' +
                  '          <td>'+data.customName+'</td>\n' +
                  '          <td>'+sex+'</td>\n' +
                  '          <td>'+data.telephone+'</td>\n' +
                  '          <td>'+data.company+'</td>\n' +
                  '          <td>'+data.province.pName+''+data.city.cName+'</td>\n' +
                  '          <td>'+data.distracTime+'</td>\n' +
                  '          <td>'+data.serviceUser.uName+'</td>\n' +
                  '          <td>\n' +
                  '          \t<a href="javascript:void(0)" class="tablelink" onclick="goview('+data.customId+',\''+data.province.pName+'\',\''+data.city.cName+'\')">查看详情</a>\n' +
                  '          </td>\n' +
                  '        </tr>'
        }
        lis+=li;
        lis+='</tbody>';
        $(".tablelist").html(lis);
        $('.tablelist tbody tr:odd').addClass('odd');

        layui.use("laypage",function (){

          var laypage=layui.laypage;
          laypage.render({
            elem:"page",
            count:rel.resultData.totalCount,
            theme: '#eb5409',
            limit:rows,
            limits:[3,5,10],
            curr:currentpage,
            layout:['prev','page','next','limit','count','skip'],
            jump:function (obj,first){
              currentpage=obj.curr
              rows=obj.limit
              if (!first){
                load(currentpage,rows,company,customName,province,city)
              }
            }

          })
        })
      })
    }
        function goview(customId,province,city){
            location.href="../customer/customerView.html?customid="+customId+"&province="+province+"&city="+city
        }
  </script>
<script type="text/javascript">
function tipOpen(content) {
	$(".tipright p").text(content);
	$("#tip").fadeIn(200);
}
function tipClose() {
	$("#tip").fadeOut(200);
}
</script>
</head>

<body>
<div class="place"> <span>位置：</span>
  <ul class="placeul">
    <li>营销管理</li>
    <li>客户浏览</li>
    <li>基本内容</li>
  </ul>
</div>
<div class="rightinfo">
  <form action="" method="post">
    <ul class="tools">
      <li> 公司名称:
        <input type="text"  id="company"/>
      </li>
      <li> 客户姓名:
        <input type="text" id="customname"/>
      </li>
      <li> 所属区域：
        <select id="country" >
          <option value="0">请选择省份</option>
          <option value="1">江西</option>
          <option value="2">广东</option>
          <option value="3">江苏</option>
          <option value="4">安徽</option>
          <option value="5">浙江</option>
          <option value="6">贵州</option>
          <option value="7">四川</option>
          <option value="8">重庆</option>
          <option value="9">湖南</option>
        </select>
        <select id="city">
          <option value="0">请选择城市</option>
        </select>
      </li>
      <li class="subBut"><img src="../../images/t06.png" />查询</li>
    </ul>
    <table class="tablelist">
<!--      <thead>-->
<!--        <tr>-->
<!--          <th>序号</th>-->
<!--          <th>客户姓名</th>-->
<!--          <th>性别</th>-->
<!--          <th>联系电话</th>-->
<!--          <th>所属公司</th>-->
<!--          <th>所属区域</th>-->
<!--          <th>分配时间</th>-->
<!--          <th>客服人员</th>-->
<!--          <th>操作</th>-->
<!--        </tr>-->
<!--      </thead>-->
<!--      <tbody>-->
<!--        <tr>-->
<!--          <td>1</td>-->
<!--          <td>王金平</td>-->
<!--          <td>男</td>-->
<!--          <td>17370899727</td>-->
<!--          <td>阿里巴巴</td>-->
<!--          <td>江苏南京</td>-->
<!--          <td>2013-09-09 15:05:05</td>-->
<!--          <td>管理员</td>-->
<!--          <td>-->
<!--          	<a href="customerView.html" class="tablelink">查看详情</a>-->
<!--          </td>-->
<!--        </tr>-->
<!--        <tr>-->
<!--          <td>2</td>-->
<!--          <td>张永祥</td>-->
<!--          <td>女</td>-->
<!--          <td>17370897894</td>-->
<!--          <td>腾讯公司</td>-->
<!--          <td>江苏南京</td>-->
<!--          <td>2013-09-09 15:05:05</td>-->
<!--          <td>管理员</td>-->
<!--          <td>-->
<!--          	<a href="customerView.html" class="tablelink">查看详情</a>-->
<!--          </td>-->
<!--        </tr>-->
<!--        <tr>-->
<!--          <td>3</td>-->
<!--          <td>王金平</td>-->
<!--          <td>男</td>-->
<!--          <td>17370899727</td>-->
<!--          <td>阿里巴巴</td>-->
<!--          <td>江苏南京</td>-->
<!--          <td>2013-09-09 15:05:05</td>-->
<!--          <td>管理员</td>-->
<!--          <td>-->
<!--          	<a href="customerView.html" class="tablelink">查看详情</a>-->
<!--          </td>-->
<!--        </tr>-->
<!--        <tr>-->
<!--          <td>4</td>-->
<!--          <td>张永祥</td>-->
<!--          <td>女</td>-->
<!--          <td>17370897894</td>-->
<!--          <td>腾讯公司</td>-->
<!--          <td>江苏南京</td>-->
<!--          <td>2013-09-09 15:05:05</td>-->
<!--          <td>管理员</td>-->
<!--          <td>-->
<!--          	<a href="customerView.html" class="tablelink">查看详情</a>-->
<!--          </td>-->
<!--        </tr>-->
<!--      </tbody>-->
    </table>
    <div class="pagin" id="page">
<!--      <ul class="paginList">-->
<!--        <li class="paginItem"><a href="javascript:;"><span class="pagepre"></span></a></li>-->
<!--        <li class="paginItem"><a href="javascript:;">1</a></li>-->
<!--        <li class="paginItem current"><a href="javascript:;">2</a></li>-->
<!--        <li class="paginItem"><a href="javascript:;">3</a></li>-->
<!--        <li class="paginItem"><a href="javascript:;">4</a></li>-->
<!--        <li class="paginItem"><a href="javascript:;">5</a></li>-->
<!--        <li class="paginItem more"><a href="javascript:;">...</a></li>-->
<!--        <li class="paginItem"><a href="javascript:;">10</a></li>-->
<!--        <li class="paginItem"><a href="javascript:;"><span class="pagenxt"></span></a></li>-->
<!--      </ul>-->
    </div>
  </form>
</div>
<script type="text/javascript">
	$('.tablelist tbody tr:odd').addClass('odd');
</script>
</body>
</html>
